package com.insurance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.insurance.domain.entity.Permission;
import com.insurance.mapper.PermissionMapper;
import com.insurance.service.PermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * (Permission)表服务实现类
 *
 * @author makejava
 * @since 2023-03-28 15:23:30
 */
@Service("permissionService")
@Transactional
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {

    //@Override
    //public List<String> selectRermByUserId(Long id) {
    //    //如果是超级管理员，返回所有的权限
    //    if(id==1){
    //        LambdaQueryWrapper<Permission> queryWrapper=new LambdaQueryWrapper<>();
    //        queryWrapper.in(Permission::getType, SystemConstants.MENU,SystemConstants.BUTTON);
    //        //逻辑删判断会自动加上
    //        List<Permission> menus = list(queryWrapper);
    //        List<String> perms = menus.stream().map(Permission::getCode).collect(Collectors.toList());
    //        return perms;
    //    }
    //    //否则返回所具有的权限
    //    return getBaseMapper().findPermissionListByUserId(id);
    //}


    @Override
    public List<Permission> findPermissionListByUserId(Long id) {
        return baseMapper.findPermissionListByUserId(id);
    }
}
